<template>
	<view>
		<view class="content">
			<view class="info" v-if="info">
				<view class="title">第{{info.classNo}}节 {{info.className}}</view>
				<view class="title-2">{{info.description}}</view>
				<view class="remark">
					<jyf-parser :html="info.content"></jyf-parser>
				</view>
			</view>
		</view>
		
		
		<view class="safe-area-inset-bottom" style="height: 120rpx;box-sizing: content-box;"></view>
		<view class="next safe-area-inset-bottom u-flex">
			<view @click="getSection(1)">下一节</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				class_id:'',
				info:''
			}
		},
		methods: {
			getSection(next = 0){
				this.$u.api.courseSection({
					class_id:this.class_id,
					next:next
				}).then(res=>{
					if(res == null){
						this.$u.toast('暂无更多章节')
						return
					}
					this.class_id = res.id
					this.info = res
					
					if(!res.buy && !res.free){
						if (getCurrentPages().length === 1) {
							this.$app.jump('/pages/index/index',!0)
						} else {
							this.$app.back()
						}
					}
				})
			}
		},
		onLoad(o) {
			this.class_id = o.id
			this.getSection()
		}
	}
</script>

<style lang="scss">
	.content{
		padding: 0 50rpx;
		.info{
			padding-top: 30rpx;
			.title{font-weight: bold;}
			.remark{padding-top: 40rpx;padding-bottom: 30rpx;}
		}
	}
	
	.next{position: fixed;left: 0;height: 119rpx;bottom: 0rpx;background-color: #fff;width: 100%;
		z-index: 99;box-sizing: content-box;border-top: 1rpx solid #ddd;justify-content: center;
		view{background-color: $tc;color: #fff;text-align: center;width: 88%;line-height: 70rpx;font-weight: bold;border-radius: 100rpx;}
	}
</style>
